package com.socialbank.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.nybank.activity.bean.BankActivity;
import com.nybank.activity.bean.BankActivityGrade;
import com.nybank.activity.bean.BankActivityUser;
import com.nybank.activity.service.BankActivityService;

@Controller
@RequestMapping("bank/activity")
public class BankActivityController {
	
	@Autowired
	private BankActivityService bankActivityService;
	
	@RequestMapping("/saveActivity")//添加活动
	@ResponseBody
	public Object saveActivity(MultipartFile file,BankActivity bankActivity){
		return bankActivityService.saveActivity(file,bankActivity,1);
	}
	
	@RequestMapping("/saveActivityGrade")
	@ResponseBody
	public Object saveActivityGrade(BankActivityGrade bankActivityGrade){
		return bankActivityService.saveActivityGrade(bankActivityGrade);
	}
	
	@RequestMapping("/saveActivityList")
	@ResponseBody
	public Object saveActivityList(BankActivityUser bankActivityList){
		return bankActivityService.saveActivityUser(bankActivityList);
	}
	
	@RequestMapping("/deleteActivityById")//通过id删除
	@ResponseBody
	public Object DeleteActivityById(int id){
		return bankActivityService.deleteActivityById(id);
	}
	
	@RequestMapping("/deleteActivityGradeById")
	@ResponseBody
	public Object DeleteActivityGradeById(int id){
		return bankActivityService.deleteActivityGradeById(id);
	}
	
	@RequestMapping("/deleteActivityListById")
	@ResponseBody
	public Object DeleteActivityListById(int id){
		return bankActivityService.deleteActivityUserById(id);
	}
	
	@RequestMapping("/getActivityByDeptId")//显示列表
	@ResponseBody
	public Object GetActivityByDeptId(String checkStatus){
		return bankActivityService.getActivityByDeptId(checkStatus==null?0:Integer.parseInt(checkStatus),1);
	}
	
	@RequestMapping("/getActivityGradeByDeptId")
	@ResponseBody
	public Object GetActivityGradeByDeptId(){
		return bankActivityService.getActivityGradeByDeptId(1);
	}
	
	@RequestMapping("/grade/statistic")
	@ResponseBody
	public Object getActivityGradeStatistical(HttpServletRequest request,int activityId){
		return bankActivityService.getActivityGradeStatistical(activityId);
	}
	
	@RequestMapping("/getActivityListByDeptId")
	@ResponseBody
	public Object GetActivityListByDeptId(BankActivityUser activityList){
		return bankActivityService.getActivityUserByDeptId(activityList,1);
	}
	
	@RequestMapping("/updateActivityById")//通过id编辑
	@ResponseBody
	public Object UpdateActivityById(MultipartFile file,BankActivity bankActivity){
		return bankActivityService.updateActivityById(file,bankActivity,1);
	}
	
	@RequestMapping("/setCheckStatus")
	@ResponseBody
	public Object setCheckStatus(int checkStatus,int id){
		return bankActivityService.setCheckStatus(checkStatus,id);
	}
	
	@RequestMapping("/getActivityById")
	@ResponseBody
	public Object getActivityById(int id){
		return bankActivityService.getActivityById(id);
	}
	
	@RequestMapping("/getActivityListCountByDay")
	@ResponseBody
	public Object getActivityListCountByDay(Integer activityId,Integer day){
		return bankActivityService.getActivityUserCountByDay(activityId,day);
	}
}
